package main

import (
	"fmt"
	"harbor-tools/utils"
	"time"
)

const (
	botToken = "1073352686:AAGU6nKsY6Y7z0L0wlqp48XL6Douqq6iXjU"
	chatId   = "-320706025"
)

func main() {
	version := fmt.Sprintf("v%d%d%d%d%d%d",
		time.Now().Year(),
		time.Now().Month(),
		time.Now().Day(),
		time.Now().Hour(),
		time.Now().Minute(),
		time.Now().Second())
	repos := utils.Run()
	for _, r := range repos {
		// docker pull
		utils.DockerPull(r)
		// docker tag new version then docker push
		utils.DockerPush(r, version)
	}
	message := fmt.Sprintf("uat version => %s", version)
	tg := utils.NewTgInfo(botToken, chatId, message)
	b := tg.SendMes()
	if b {
		fmt.Println("tg message send successed!")
	} else {
		fmt.Println("tg message send failed!")
	}
	// delete old images
	//utils.DeleteOldImages("mkcp", 10)
	//utils.DeleteOldImages("cp", 10)
}
